window.onload =
    function()
    {
        function hideAndShowUlElements(ev)
        {
            var ulElements = this.getElementsByTagName('ul');

            if (this === ev.target && ulElements[0].style.display === 'block')
            {
                ulElements[0].style.display = 'none';
            }
            else
            {
                ulElements[0].style.display = 'block';
            }
        }

        var liElements = document.getElementsByTagName('li');

        for (var i = 0; i < liElements.length; i++)
        {
            liElements[i].addEventListener('click', hideAndShowUlElements);
        }
    };